package org.itli.wacp.Util;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;

@Slf4j
public class ThreadLocalUtil {
    //提供ThreadLocalUntil对象
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();
    //THREAD_LOCAL 这个变量在内存中只有一个实例

    private int count=0;



    //根据健获取值
    public static String get(){
        log.info("拿出数据"+(String) THREAD_LOCAL.get());
        return (String) THREAD_LOCAL.get();
    }

    //存入值
    public static void set(Object value){
        THREAD_LOCAL.set(value);
        log.info("已经写入数据"+value);
    }

    //清除，防止内存泄露
    public static void remove(){
        log.info("清理内存");
        THREAD_LOCAL.remove();
    }
}
